<?php
/**
 * User信息
 *
 */
class UserModel {

	static function GetTableName()
	{
		return  'user';
	}

	static function Db() {
		return ApiDB::Instance($GLOBALS['CONFIG_DATABASE']);
	}

	static function add($token, $wbid) {
		$tablename = self::GetTableName();

		$condition = array(
                    'wbid' => $wbid,
                    'access_token' => $token,
                    );
		$ApiDB = self::Db();
		$result = $ApiDB->Insert($tablename, $condition);
		return $result;
	}

	static function show($token, $uid=null) {
		$c = new SaeTClientV2( SINAWB_AKEY , SINAWB_SKEY , $token );
		$uid_get = $c->get_uid();
		$uid = $uid_get['uid'];
		return $c->show_user_by_id( $uid);//根据ID获取用户等基本信息
	}

}
